/*
 * Filename: e:\OwnProject\FlutterPro\flutter_app_01\lib\modules\Account.dart
 * Path: e:\OwnProject\FlutterPro\flutter_app_01\lib\modules
 * Created Date: Friday, April 2nd 2021, 11:04:40 am
 * Author: chenfayun
 * 
 * Copyright (c) 2021 Your Company
 */

class Category {
  String type;
  String name;

  Category(this.type, this.name);

  String get src => 'images/$type.png';
}

class AccountItem {
  late String? name;
  late String? id;
  late String? pwd;
  late String? remark;
  late String type;

  AccountItem({this.name, this.id, this.pwd, this.remark, required this.type});

  AccountItem.fromJson(Map<String, dynamic> map) {
    name = map['name'] ?? "";
    id = map['id'] ?? "";
    pwd = map['pwd'] ?? "";
    remark = map['remrk'] ?? "";
    type = map['type'] ?? "";
  }

  Map<String, dynamic> toJSONEncodable() {
    Map<String, dynamic> m = {};
    m['name'] = name;
    m['id'] = id;
    m['pwd'] = pwd;
    m['remark'] = remark;
    m['type'] = type;
    return m;
  }
}

class AccountList {
  List<AccountItem> accounts = [];
  static final categories = {
    'wx': Category('wx', 'WeChat'),
    'wb': Category('wb', 'Sina Weibo'),
    'qq': Category('qq', 'QQ'),
    'dy': Category('dy', 'Douyin'),
    'baidu': Category('baidu', 'Baidu'),
    'douban': Category('douban', 'Douban'),
    'faceBook': Category('facebook', 'Facebook'),
    'google': Category('google', 'Google'),
    'ins': Category('ins', 'Ins'),
    'Line': Category('Line', 'Line'),
    'twitter': Category('twitter', 'Twitter'),
    'youku': Category('youku', 'Youku'),
    'youtube': Category('youtube', 'Youtube'),
    'zhihu': Category('zhihu', 'Zhihu'),
  };
  toJSONEncodable() => accounts.map((e) => e.toJSONEncodable()).toList();
}
